package id.co.shuba.spamobile.task;

import android.os.AsyncTask;

public abstract class BaseProgressTask extends
	AsyncTask<Object, Integer, AsyncTaskResult<Void>> {
	private OnStatusChangedListener _statusListener;
	private OnProgressChangedListener _progressListener;
	private int _progress;
	private String _status;
	
	public void publishStatus(String status) {
		_status = status;
		if (_statusListener != null)
			_statusListener.onStatusChanged(status);
	}
	
	public String getStatusMessage() {
		return _status;
	}
	
	@Override
	protected void onProgressUpdate(Integer... values) {
		_progress = values[0];
		if (_progressListener != null)
			_progressListener.onProgressChanged(values[0]);
	}	
	
	public void setStatusListener(OnStatusChangedListener listener) {
		_statusListener = listener;
	}
	
	public void setProgressChangedListener(OnProgressChangedListener listener) {
		_progressListener = listener;
	}
	
	public abstract String getTitle();
	
	public int getProgress() {
		return _progress;
	}
}
